/**
 * Created by sfr on 2017/10/10.
 */
import React from "react";
import {connect} from "dva";
import { createForm } from 'rc-form';
import { routerRedux } from 'dva/router';
import moment from 'moment';
import {ImagePicker, Button, TextareaItem, WhiteSpace, DatePicker, List  } from "antd-mobile";
import styles from './taskAdd.less';
const empty = require('is-empty');

class TaskAdd extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      files: [],//上传的图片
    };
  }
  //==生命周期--页面渲染
  render() {
    const { files } = this.state;
    const { getFieldProps } = this.props.form;
    return (
      <div className='taskAdd' style={{backgroundColor: '#eee'}}>
        <WhiteSpace />
        <WhiteSpace />
        <TextareaItem
          title="任务标题"
          placeholder="请输入工作标题"
          data-seed="logId"
          autoHeight
        />
        <WhiteSpace />
        <div className={styles.taskDeatil}>任务详情</div>
        <TextareaItem
          autoHeight
          placeholder="请输入任务详情的内容"
          labelNumber={5}
          style={{padding: '0 0.3rem'}}
        />
        <div className={styles.imgeUploader}>
          <ImagePicker
            files={files}
            onChange={this.onChange}
            onImageClick={(index, fs) => console.log(index, fs)}
            selectable={files.length < 9}
          />
        </div>
        <WhiteSpace />
        <List>
          <DatePicker  
            mode="date"
            title="选择开始时间"
            {...getFieldProps('startTime', {

            })}>
            <List.Item arrow="horizontal">开始时间</List.Item>
          </DatePicker>
          <DatePicker  
            mode="date"
            title="选择结束时间"
            {...getFieldProps('endTime', {

            })}>
            <List.Item arrow="horizontal">结束时间</List.Item>
          </DatePicker>
        </List>
        <WhiteSpace />
        <WhiteSpace />
        <WhiteSpace />
        <WhiteSpace />
        <WhiteSpace />
        <WhiteSpace />
        <div className={styles.addBtn}> 
          <Button >提交</Button>
        </div>
        <WhiteSpace />
        <WhiteSpace />
      </div>
    );
	}
  //==组件所有函数
  //上传图片
  onChange = (files, type, index) => {
    console.log(files, type, index);
    this.setState({
      files,
    });
  }
  //开始时间改变
  startTimieOnChange = (date) => {
    console.log('onChange', date);
    this.setState({
      startTime: date
    });
  }
  //结束时间改变
  endTimieOnChange = (date) => {
    console.log('onChange', date);
    this.setState({
      endTime: date
    });
  }
}

function mapStateToProps({ infor }){
  return {
    infor
	};
}

const Wrapper = createForm()(TaskAdd);

export default connect(mapStateToProps)(Wrapper);